<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Document</title>
</head>

<body>
  <div id="app">
    <input type="text" v-model="firstName" />
    <input type="text" v-model="lastName" />
    <p>变量拼接： {{firstName + " " + lastName}}</p>
    <p>方法调用： {{getFullName()}}</p>
    <p>计算属性： {{fullName}}</p>

    <p>{{count}}</p>
    <button @click="count++">++++</button>
  </div>

  <script src="https://cdn.jsdelivr.net/npm/vue@2.7.8/dist/vue.js"></script>
  <script>
    Vue.config.productionTip = false;
    const app = new Vue({
      el: "#app",
      data: {
        firstName: "",
        lastName: "",
        count: 0,
      },
      // 计算属性:依赖于data中的变量,进行一定的计算,返回计算后的结果作为该属性的值,computed中的属性不能和data中的重复
      computed: {
        fullName() {
          console.log("computed");
          return this.firstName + " " + this.lastName;
        },
      },
      methods: {
        getFullName() {
          console.log("methods");
          return this.firstName + " " + this.lastName;
        },
      },
    });
  </script>
</body>

</html>